Skip to content

feat: change external storage CLI output to JSON format#3

Closed
minodisk wants to merge 10 commits intomainfrom
feature/external-uploader-cli
Closed

feat: change external storage CLI output to JSON format#3
minodisk wants to merge 10 commits intomainfrom
feature/external-uploader-cli

Conversation

@minodisk
Copy link
Copy Markdown
Owner

Summary

  • Change external upload CLI output from two lines to JSON format
  • Upload command outputs: {"url":"...","id":"..."}
  • Delete command outputs: {}

Background

Based on feedback from k1LoW#481 (comment)

Having the information split into two lines is confusing; if it's a single set of information, it would be better to keep it on one line.

JSON format was chosen for:

  • Easier parsing
  • Better extensibility
  • Common CLI pattern (like aws, gh)

Test plan

  • Build passes
  • Tests pass

🤖 Generated with Claude Code

minodisk and others added 10 commits December 26, 2025 09:12
Add -u (--image-upload-command) and -d (--image-delete-command) flags
to allow using external CLI tools for image upload and deletion instead
of Google Drive.

The external CLI receives image data via stdin and environment variables:
- DECK_UPLOAD_MIME: MIME type of the image
- DECK_UPLOAD_FILENAME: suggested filename
- DECK_DELETE_ID: resource ID to delete

The upload command should output:
- Line 1: public URL of the uploaded image
- Line 2: resource ID for later deletion

This enables integration with custom storage backends like GCS, S3, or
any other service via CLI wrappers, similar to how laminate works for
code block to image conversion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add support for CEL template expressions in image upload/delete commands,
similar to how -c (code-block-to-image-command) works.

Upload command (-u) supports:
- {{mime}} - MIME type of the image
- {{filename}} - suggested filename
- {{env.XXX}} - environment variables

Delete command (-d) supports:
- {{id}} - resource ID to delete
- {{env.XXX}} - environment variables

Implementation:
- Extract template expansion logic into new `template` package
- Move tests from md/template_test.go to template/template_test.go
- Update md and deck packages to use the shared template package

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The filename is not used by external uploaders like reprint-gcs,
which generate their own object IDs using UUIDs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename uploader.go to storage.go
- Rename Uploader interface to Storage
- Rename googleDriveUploader to googleDriveStorage
- Rename externalUploader to externalStorage
- Inline constants (DECK_UPLOAD_MIME, DECK_DELETE_ID) into functions
- Inline generateTempFilename() into googleDriveStorage.Upload()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change the output format from two lines (URL and ID) to JSON:
- Upload: {"url":"...","id":"..."}
- Delete: {}

This follows the common CLI pattern and is easier to extend.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@minodisk minodisk closed this Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant